package com.akita.spring.ai.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/ai")
public class GameController {

    @Resource
    private ChatClient aliGameChatClient;

    @RequestMapping(value = "/game", produces = "text/html;charset=UTF-8")
    public Flux<String> game(String prompt, String chatId) {
        // 发送消息
        return aliGameChatClient.prompt()
                .user(prompt)
                .advisors(advisorSpec -> advisorSpec.param("chatId", chatId))
                .stream()
                .content();
    }
}
